<?php

namespace app\models\Child;

use Yii;

/**
 * This is the model class for table "t_off_info".
 *
 * @property integer $off_id
 * @property integer $user_id
 * @property string $off_day
 * @property string $create_time
 */
class TOffInfo extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 't_off_info';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['user_id'], 'integer'],
            [['create_time'], 'safe'],
            [['off_day'], 'string', 'max' => 10],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'off_id' => 'Off ID',
            'user_id' => 'User ID',
            'off_day' => 'Off Day',
            'create_time' => 'Create Time',
        ];
    }
    
    /*
     * 获取医生请假时间
     */
    public function getList($doctor_id)
    {
        $list = $this->find()
                ->where(['user_id' => $doctor_id])
                ->asArray()
                ->all();
        return $list;
    }
    
    /*
     * 校验医生是否请假
     */
    public function getLists($doctor_id,$booking_times)
    {
	$list = $this->find()
		->where(['user_id' => $doctor_id,'off_day' => $booking_times])
		->asArray()
		->one();
	return $list;
    }
}
